package io.adrainty.bolee.framework.feign.config;

import com.fasterxml.jackson.databind.ObjectMapper;
import io.adrainty.bolee.framework.commons.utils.JsonUtil;
import io.adrainty.bolee.framework.feign.interceptor.FeignAuthInterceptor;
import org.springframework.boot.autoconfigure.http.HttpMessageConverters;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;

/**
 * @author AdRainty
 * @version V1.0.0
 * @since 2025/7/27 下午11:23
 */

@Configuration
@SuppressWarnings("rawtypes")
public class FeignConfig {

    @Bean
    public FeignAuthInterceptor feignAuthInterceptor() {
        return new FeignAuthInterceptor();
    }

    @Bean
    public ObjectMapper objectMapper() {
        return JsonUtil.getMapper();
    }

    @Bean
    public HttpMessageConverters httpMessageConverters() {
        HttpMessageConverter jacksonConverter = new MappingJackson2HttpMessageConverter(JsonUtil.getMapper());
        return new HttpMessageConverters(jacksonConverter);
    }

}
